package com.shushan.pages.bean;

import com.android.net.bean.NetBaseBean;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * @ClassName: TypesExerciseRecordBean
 * @Desciption: //各练习类型记录统一bean
 * @author: zhangshihao
 * @date: 2018-04-21
 */
public class TypesExerciseRecordBean extends NetBaseBean {

    public int type;//习题类型
    public String[] press_names = new String[3];//0:语文，1：数学，2：英语
    public int[] err_num_of_subjects = new int[3];//0:语文，1：数学，2：英语

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        if(jsonObject != null) {
            for (int i = 7; i < 10; i++) {
                JSONObject jobj = jsonObject.optJSONObject(i + "");

                if(jobj == null || jobj.toString().equals("{}")){
                    press_names[i-7] = "";
                    err_num_of_subjects[i-7] = 0;
                    continue;
                }
                press_names[i-7] = jobj.optString("press_name");
                err_num_of_subjects[i-7] = jobj.optInt("num");

            }
        }
    }

    @Override
    public boolean equals(Object obj) {
        if(this == obj){   //同一个对象则相同
            return true;
        }
        if(obj == null){   //传入对象为空则不相同
            return false;
        }
        if(getClass() != obj.getClass()){ // 类型不同则不同
            return false;
        }

        TypesExerciseRecordBean recordBean = (TypesExerciseRecordBean)obj;
        return type == recordBean.type;
    }
}
